package com.hs.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.hs.room.model.archive.Case
import kotlinx.coroutines.flow.Flow

@Dao
interface CaseDao {

    @Insert
    suspend fun insert(d: Case)

    @Update
    suspend fun update(d: Case): Int

    @Query("SELECT * FROM case_tb where :caseNo = caseNo")
    fun selectByName(caseNo: String): Case

    @Query("SELECT * FROM case_tb")
    fun getAll(): Flow<List<Case>>

    @Query("SELECT * FROM case_tb ORDER BY localId LIMIT :limit OFFSET :offset ")
    fun get(limit: Int, offset: Int): Flow<List<Case>>

    @Query("SELECT count(*) FROM case_tb")
    fun count(): Int

    @Delete
    suspend fun delete(d: Case)
}